package com.allqj.sfx.infrastructure.repository;

import com.allqj.sfx.domain.entity.TableHeader;
import com.allqj.sfx.domain.repository.TableHeaderRepository;
import com.allqj.sfx.infrastructure.converter.TableHeaderConverter;
import com.allqj.sfx.infrastructure.dao.TableHeaderDAO;
import com.allqj.sfx.infrastructure.po.TableHeaderDO;
import org.springframework.stereotype.Repository;

/**
 * @author sjw
 * @className TableHeaderRepositoryImpl
 * @date 2022/7/21 9:48
 * @description: TableHeaderRepository具体实现
 * Repository接口定义位于domain层
 * Repository接口具体实现位于infrastructure层
 * 与底层db解耦
 */
@Repository
public class TableHeaderRepositoryImpl implements TableHeaderRepository {
    private final TableHeaderDAO dao;

    public TableHeaderRepositoryImpl(TableHeaderDAO dao) {
        this.dao = dao;
    }

    @Override
    public TableHeader queryByTable(Integer tableId) {
        TableHeaderDO tableHeaderDO = dao.findByTableIdAndIsdeleteFalse(tableId);
        return TableHeaderConverter.INSTANCE.do2Entity(tableHeaderDO);
    }
}
